package main

/**
 * Forward declaration of guess API.
 * @param  num   your guess
 * @return 	     -1 if num is higher than the picked number
 *			      1 if num is lower than the picked number
 *               otherwise return 0
 * func guess(num int) int;
 */

// 1-n随机选择一个数据
func guessNumber(n int) int {
	l, r := 0, n
	for {
		num := l + (r-l)>>1
		res := guess(num)
		if res == 0 {
			return num
		} else if res == 1 {
			l = num + 1
		} else {
			r = num
		}
	}
}

var picked = 123

func guess(n int) int {
	if n > picked {
		return -1
	} else if n < picked {
		return 1
	} else {
		return 0
	}
}
